<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <!-- Meta, title, CSS, favicons, etc. -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>签收订单页面</title>

  <!-- Bootstrap -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link href="css/font-awesome.min.css" rel="stylesheet">
  <!-- NProgress -->
  <!--<link href="css/nprogress.css" rel="stylesheet">-->

  <!-- Custom Theme Style -->
  <link href="css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
  <div class="main_container">
    <div id="head">
    </div>

    <!-- page content -->
    <div class="right_col" role="main">
      <div class="">
        <div class="row">
          <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">

              <div class="x_content">

                <form class="form-horizontal form-label-left" novalidate id="myfrom">


                  <span class="section">请确定签单信息</span>

                  <div class="item form-group">
                    <label id="label1" class="control-label col-md-3 col-sm-3 col-xs-12" for="orderid">订单号
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="orderid" class="form-control col-md-7 col-xs-12"  readonly="readonly"  type="text" value="">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="SENDERNAME">寄件人
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="SENDERNAME" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="A_PHONE">寄件人联系方式
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="A_PHONE" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="GTYPE">货物描述
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="GTYPE" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>

                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="WEIGHT">货物重量
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="WEIGHT" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="VOLUME">货物体积
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="VOLUME" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="RECIPIENTS">收件人
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="RECIPIENTS" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="B_PHONE">收件人联系方式
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="B_PHONE" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="address">收件人详细地址
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="address" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="s_name">负责人
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="s_name" class="form-control col-md-7 col-xs-12" readonly="readonly" value="" type="text">
                    </div>
                  </div>
                  <div class="item form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="CREATETIME">下单时间
                    </label>
                    <div class="col-md-6 col-sm-6 col-xs-12">
                      <input id="CREATETIME" class="form-control col-md-7 col-xs-12" readonly="readonly" value=""  type="text">
                    </div>
                  </div>



                </form>
                <div class="ln_solid"></div>
                <div class="form-group">
                  <div class="col-md-6 col-md-offset-3">
                    <a href="javascript:;" class="btn btn-primary" onclick="window.history.back(-1)">返回</a>
                    <a id="send" href="javascript:;" class="btn btn-success">确定签单</a>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /page content -->

    <!-- footer content -->
    <footer>

      <div class="clearfix"></div>
    </footer>
    <!-- /footer content -->
  </div>
</div>


<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="js/fastclick.js"></script>
<!-- NProgress -->
<!--<script src="js/nprogress.js"></script>-->
<!-- validator -->
<script src="js/validator.js"></script>

<!-- Custom Theme Scripts -->
<script src="js/custom.min.js"></script>

<!-- validator -->
<script>
    $(function(){
        17
        $(".pimg").click(function(){
            18
            var _this = $(this);//将当前的pimg元素作为_this传入函数
            19
            imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
            20
        });
        21
    });
    function imgShow(outerdiv, innerdiv, bigimg, _this){

        var src = _this.attr("src");//获取当前点击的pimg元素中的src属性

        $(bigimg).attr("src", src);//设置#bigimg元素的src属性
        /*获取当前点击图片的真实大小，并显示弹出层及大图*/

        $("<img/>").attr("src", src).load(function(){

            var windowW = $(window).width();//获取当前窗口宽度

            var windowH = $(window).height();//获取当前窗口高度

            var realWidth = this.width;//获取图片真实宽度

            var realHeight = this.height;//获取图片真实高度

            var imgWidth, imgHeight;

            var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放



            if(realHeight>windowH*scale) {//判断图片高度

                imgHeight = windowH*scale;//如大于窗口高度，图片高度进行缩放

                imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度

                if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度

                    imgWidth = windowW*scale;//再对宽度进行缩放

                }

            } else if(realWidth>windowW*scale) {//如图片高度合适，判断图片宽度

                imgWidth = windowW*scale;//如大于窗口宽度，图片宽度进行缩放

                imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度

            } else {//如果图片真实高度和宽度都符合要求，高宽不变

                imgWidth = realWidth;

                imgHeight = realHeight;

            }

            $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放



            var w = (windowW-imgWidth)/2;//计算图片与窗口左边距

            var h = (windowH-imgHeight)/2;//计算图片与窗口上边距

            $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性

            $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg

        });



        $(outerdiv).click(function(){//再次点击淡出消失弹出层

            $(this).fadeOut("fast");

        });

    }
    // initialize the validator function
    validator.message.date = 'not a real date';

    // validate a field on "blur" event, a 'select' on 'change' event & a '.reuired' classed multifield on 'keyup':
    $('form')
        .on('blur', 'input[required], input.optional, select.required', validator.checkField)
        .on('change', 'select.required', validator.checkField)
        .on('keypress', 'input[required][pattern]', validator.keypress);

    $('.multi.required').on('keyup blur', 'input', function() {
        validator.checkField.apply($(this).siblings().last()[0]);
    });

    $('form').submit(function(e) {
        e.preventDefault();
        var submit = true;

        // evaluate the form using generic validaing
        if (!validator.checkAll($(this))) {
            submit = false;
        }

        if (submit)
            this.submit();

        return false;
    });
</script>
<!-- /validator -->

<!-- jQuery Smart Wizard -->
<script>
    $(document).ready(function() {
        $("#head").load("head.html");
        $('.buttonNext').addClass('btn btn-success');
        $('.buttonPrevious').addClass('btn btn-primary');
        $('.buttonFinish').addClass('btn btn-default');
    });

    <!--页面初始化ajax-->
    var $token=window.sessionStorage.getItem('token');
    var $url=window.location.href;
    var $ordid=$url.split("=")[1];
    function   formatDate(now)   {
        var   year=now.getFullYear();
        var   month=now.getMonth()+1;
        var   date=now.getDate();
        return   year+"-"+month+"-"+date;
    }

    $.ajax({
        type:"post",
        xhrFields:{withCredentials:true},
        url:"http://localhost:8081/OrderController/queryorderbyid",
        dataType:"json",
        data:{"ordid":$ordid,"token":$token},
        success:function (data) {
            if(data!=null){
                var   $createtime=new   Date(data.createtime);
                $("#orderid").val(data.orderNumber);
                $("#SENDERNAME").val(data.senderName);
                $("#A_PHONE").val(data.aPhone);
                $("#GTYPE").val(data.goodDescription);
                $("#WEIGHT").val(data.goodWeight+"KG");
                $("#VOLUME").val(data.goodVolume+"m³");
                $("#RECIPIENTS").val(data.recipients);
                $("#B_PHONE").val(data.bPhone);
                $("#address").val(data.addressee);
                $("#s_name").val(data.sname);
                $("#CREATETIME").val(formatDate($createtime));
                if(data.insurePicPath==null||data.insurePicPath==""){

                }else{
                    $("#myfrom").append('\n' +
                        '                       <div class="item form-group">\n' +
                        '                       \t<label class="control-label col-md-3 col-sm-3 col-xs-12" for="INSUREPICPATH">保单</label>\n' +
                        '                      \t<ul id="1INSUREPICPATH">\n' +
                        '   \t\t\t\t\t\t <li>\n' +
                        '                        \t\t\t<img id="INSUREPICPATH" src="'+data.insurePicPath+'" width="100px" style="margin-left: 50px;" /></li>\n' +
                        '   \t\t\t\t\t\t\t</ul>\n' +
                        '\n' +
                        '                    \t\t </div>')
                }
                $("#send").attr("ordNo",data.orderNumber);
            }else{
                alert("加载错误");
            }
        },
        error:function(){
            alert("错误");
        }
    })

    $(document).on("click","#send",function () {
        var $ordno=$(this).attr("ordno");
        $.ajax({
            type:"post",
            xhrFields:{withCredentials:true},
            url:"http://localhost:8081/OrderController/finshUpdate",
            dataType:"json",
            data:{"ordno":$ordno,"token":$token},
            success:function (data) {
                if(data.message=="yes"){
                    alert("签单成功");
                    window.location.href="finish.html";
                }else{
                    alert("签单失败");
                }
            },
            error:function(){
                alert("错误");
            }
        })
    })


</script>
<!-- /jQuery Smart Wizard -->
</body>
</html>
